<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="renderer" content="webkit">
<title>自定义积分赠送</title>
<link rel="stylesheet" href="__PUBLIC__/css/pintuer.css">
<link rel="stylesheet" href="__PUBLIC__/css/admin.css">
<script src="__PUBLIC__/js/jquery.js"></script>
<script src="__PUBLIC__/js/pintuer.js"></script>
</head>
<body>
<input type="hidden" class="input w50" value="<?php echo $_SESSION['power'];?>" name="power" id="power" />
<div class="panel admin-panel">

  <div class="panel-head"><strong class="icon-reorder">自定义积分赠送配置表</strong></div>

    <div class="padding border-bottom">
        <a  class="button border-yellow" href="__URL__/setIntergral"><span class="icon-plus-square-o"></span> 新增配置时间</a>
    </div>
  <table class="table table-hover text-center">
    <tr>
        <th width="10%" style="text-align:left; padding-left:20px;">年份</th>
        <th width="10%">月份</th>
        <th width="10%">日期区间</th>
        <th width="10%">积分赠送返比</th>
        <th width="10%">运行状态</th>
        <th width="310">操作</th>
      </tr>
      <volist name="list" id="it">
      <tr>
          <td>{$it.year}</td>
          <td>{$it.moth}</td>
          <td>{$it.day_start}-{$it.day_end}</td>
          <td>{$it.ratio}</td>
          <td class="runstate">
              <if condition="$it.run_state eq 1">
                  <span class="run-status run-status-running"><i></i> 启用中</span>
                  <else />
                  <span class="run-status run-status-stoped"><i></i> 暂停</span>
              </if>
          </td>
          <td>
              <div class="button-group" id="important">
                  <a class="button border-main" href="__URL__/setIntergral?id={$it.id}"><span class="icon-edit"></span>修改</a>
                  <if condition="$it.run_state eq 1">
                      <a class="button border-red change-state" href="javascript:;" data-id="{$it.id}" data-type="{$it.run_state}"><span class="icon-edit"></span> 停止</a>
                      <else />
                      <a class="button border-main change-state" href="javascript:;" data-id="{$it.id}" data-type="{$it.run_state}"><span class="icon-edit"></span> 开启</a>
                  </if>
                  <a class="button border-red" href="__URL__/delIntergral?id={$it.id}"><span class="icon-edit"></span> 删除</a>
              </div>
          </td>

      </tr>
      </volist>
    
  </table>
</div>

<script>
    !(function ($) {
        $('.change-state').on('click',function () {
            var id          = $(this).attr('data-id');
            var type        = $(this).attr('data-type');
            var runstate    = $(this).parents('td').siblings('.runstate');
            $.post('__URL__/changeStateintegral',{id:id,type:type}).then(function (res) {
                if(res.state){
                    if(type ==0){
                        //停止状态，切换到启动状动
                        location.reload();
                        return ;
                    }
                    location.reload();
                }
            },function () {
                alert('网络请求错误')
            })
        })
    })(jQuery);
</script>
</body>
</html>